package com.landon.id.test;


import com.landon.id.generator.IdGenerator;
import com.landon.id.result.ResultWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author shishaopeng
 * Date: 2022-10-25-17-09
 * Desc:
 */
@RequestMapping("/web/id")
@RestController
@Slf4j
public class IdGenerateController {

    @Resource
    IdGenerator idGenerator;

    /**
     * 获取分布式ID
     */
    @GetMapping("/get")
    public ResultWrapper getId(@RequestParam String businessId) {
        Long longCosId = idGenerator.getLongCosId(businessId);
        log.info("获取业务：" + businessId + "：下的 id：" + longCosId);
        return ResultWrapper.success(longCosId);
    }
}
